package com.system.service.impl;

import com.system.mapper.ContactMapper;
import com.system.pojo.Contact;
import com.system.service.ContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ContactService")
public class ContactServiceImpl implements ContactService {

    @Autowired
    ContactMapper contactMapper;

    @Override
    public List<Contact> selectContact(Contact contact) {
        return contactMapper.selectContact();
    }

    @Override
    public List<Contact> selectContactByPage(Contact contact, int page, int limit) {
        int starRow = (page-1)*limit+1;
        int endRow  = page*limit;
        String personName = contact.getPersonName();

        return contactMapper.selectContactByPage(personName,starRow,endRow);
    }

    @Override
    public void delContact(Integer personId) {
        contactMapper.delContact(personId);
    }

    @Override
    public void updateContact(Contact contact) {
        contactMapper.updateContact(contact);
    }

    @Override
    public void insertContact(Contact contact) {
        contactMapper.insertContact(contact);
    }
}
